home *** CD-ROM | disk | FTP | other *** search
/ Programmers Heaven 2 / Programmers Heaven 2.iso / files / graphics / library / wgt51_r2.zip / WGT5 / EXAMPLES / WGT08.C < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-03  |  2.5 KB  |  81 lines

  1. /*
  2. ==============================================================================
  3.                       WordUp Graphics Toolkit Version 5.0 
  4.                              Demonstration Program 8                          
  5.                                                                               
  6.  Shows how the region fill function works with various shapes.                
  7.                                                                               
  8.  *** PROJECT ***                                                             
  9.  This program requires the file WGT5_WC.LIB to be linked.                    
  10.                                                                               
  11.  *** DATA FILES ***                                                          
  12.  NONE                                                                        
  13.                                                            WATCOM C++ VERSION 
  14. ==============================================================================
  15. */
  16.  
  17. #include <wgt5.h>
  18.  
  19.  
  20. void main(void)
  21. {
  22.   short x;
  23.   short oldmode;
  24.   color palette[256];
  25.  
  26.   printf ("WGT Example #8\n\n");
  27.   printf ("This program demonstrates the wregionfill command. First it will fill a\n");
  28.   printf ("circle and the region around it. Press a key. It will then draw 10,000\n");
  29.   printf ("random pixels and adjust the clipping. Press a key to see the fill command\n");
  30.   printf ("work with the new clipping settings. A third keypress ends the program.\n");
  31.   printf ("\n\nPress any key to continue.\n");
  32.   getch ();
  33.  
  34.   if ( !vgadetected () )
  35.   {
  36.     printf ("Error - VGA card required for any WGT program.\n");
  37.     exit (0);
  38.   }
  39.  
  40.   oldmode = wgetmode ();
  41.   vga256 ();
  42.   wcls (0);
  43.  
  44.   wsetcolor (1);
  45.   wcircle (160, 100, 50);          /* try filling a circle */
  46.   getch ();
  47.  
  48.   wsetcolor (40);
  49.   wregionfill (160, 100);
  50.   wsetcolor (170);
  51.   wregionfill (0, 0);
  52.  
  53.   getch();
  54.  
  55.   wcls (0);
  56.   for (x = 1; x < 10000; x++)     /* try filling 10,000 random pixels */
  57.   {
  58.     wsetcolor (rand () % 255);
  59.     wputpixel (rand () % 320, rand() % 200);
  60.   }
  61.   getch ();
  62.   wsetcolor (40);
  63.   wclip (50, 50, 250, 150);          /* fill works with clipping too! */
  64.   wregionfill (160, 100);
  65.  
  66.   wsetcolor (7);
  67.   wclip (10, 10, 40, 40);
  68.   wregionfill (20, 20);
  69.  
  70.   wsetcolor (9);
  71.   wclip (260, 160, 300, 190);
  72.   wregionfill (270, 170);
  73.  
  74.   wsetcolor (10);
  75.   wclip (0, 0, 319, 199);
  76.   wregionfill (0, 0);
  77.  
  78.   getch ();
  79.   wsetmode (oldmode);
  80. }
  81.